/**
 */
package OBSL.impl;

import OBSL.OBSLPackage;
import OBSL.PresentIndividual;
import OBSL.QualityCharacterizationLink;
import OBSL.QualityIndividual;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Quality Characterization Link</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link OBSL.impl.QualityCharacterizationLinkImpl#getQuality <em>Quality</em>}</li>
 *   <li>{@link OBSL.impl.QualityCharacterizationLinkImpl#getBearer <em>Bearer</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class QualityCharacterizationLinkImpl extends MinimalEObjectImpl.Container implements QualityCharacterizationLink {
	/**
	 * The cached value of the '{@link #getBearer() <em>Bearer</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBearer()
	 * @generated
	 * @ordered
	 */
	protected PresentIndividual bearer;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected QualityCharacterizationLinkImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OBSLPackage.Literals.QUALITY_CHARACTERIZATION_LINK;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public QualityIndividual getQuality() {
		if (eContainerFeatureID() != OBSLPackage.QUALITY_CHARACTERIZATION_LINK__QUALITY) return null;
		return (QualityIndividual)eInternalContainer();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetQuality(QualityIndividual newQuality, NotificationChain msgs) {
		msgs = eBasicSetContainer((InternalEObject)newQuality, OBSLPackage.QUALITY_CHARACTERIZATION_LINK__QUALITY, msgs);
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setQuality(QualityIndividual newQuality) {
		if (newQuality != eInternalContainer() || (eContainerFeatureID() != OBSLPackage.QUALITY_CHARACTERIZATION_LINK__QUALITY && newQuality != null)) {
			if (EcoreUtil.isAncestor(this, newQuality))
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
			NotificationChain msgs = null;
			if (eInternalContainer() != null)
				msgs = eBasicRemoveFromContainer(msgs);
			if (newQuality != null)
				msgs = ((InternalEObject)newQuality).eInverseAdd(this, OBSLPackage.QUALITY_INDIVIDUAL__CHARACTERIZES, QualityIndividual.class, msgs);
			msgs = basicSetQuality(newQuality, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.QUALITY_CHARACTERIZATION_LINK__QUALITY, newQuality, newQuality));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PresentIndividual getBearer() {
		if (bearer != null && bearer.eIsProxy()) {
			InternalEObject oldBearer = (InternalEObject)bearer;
			bearer = (PresentIndividual)eResolveProxy(oldBearer);
			if (bearer != oldBearer) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OBSLPackage.QUALITY_CHARACTERIZATION_LINK__BEARER, oldBearer, bearer));
			}
		}
		return bearer;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PresentIndividual basicGetBearer() {
		return bearer;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBearer(PresentIndividual newBearer) {
		PresentIndividual oldBearer = bearer;
		bearer = newBearer;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.QUALITY_CHARACTERIZATION_LINK__BEARER, oldBearer, bearer));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.QUALITY_CHARACTERIZATION_LINK__QUALITY:
				if (eInternalContainer() != null)
					msgs = eBasicRemoveFromContainer(msgs);
				return basicSetQuality((QualityIndividual)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.QUALITY_CHARACTERIZATION_LINK__QUALITY:
				return basicSetQuality(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
		switch (eContainerFeatureID()) {
			case OBSLPackage.QUALITY_CHARACTERIZATION_LINK__QUALITY:
				return eInternalContainer().eInverseRemove(this, OBSLPackage.QUALITY_INDIVIDUAL__CHARACTERIZES, QualityIndividual.class, msgs);
		}
		return super.eBasicRemoveFromContainerFeature(msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OBSLPackage.QUALITY_CHARACTERIZATION_LINK__QUALITY:
				return getQuality();
			case OBSLPackage.QUALITY_CHARACTERIZATION_LINK__BEARER:
				if (resolve) return getBearer();
				return basicGetBearer();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OBSLPackage.QUALITY_CHARACTERIZATION_LINK__QUALITY:
				setQuality((QualityIndividual)newValue);
				return;
			case OBSLPackage.QUALITY_CHARACTERIZATION_LINK__BEARER:
				setBearer((PresentIndividual)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OBSLPackage.QUALITY_CHARACTERIZATION_LINK__QUALITY:
				setQuality((QualityIndividual)null);
				return;
			case OBSLPackage.QUALITY_CHARACTERIZATION_LINK__BEARER:
				setBearer((PresentIndividual)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OBSLPackage.QUALITY_CHARACTERIZATION_LINK__QUALITY:
				return getQuality() != null;
			case OBSLPackage.QUALITY_CHARACTERIZATION_LINK__BEARER:
				return bearer != null;
		}
		return super.eIsSet(featureID);
	}

} //QualityCharacterizationLinkImpl
